﻿using System;
using System.Data;
using System.Collections.Generic;
using SERP.DAO;
namespace SERP.Controllers{
public class ModulesControllerBase : Controller{
	public ModulesControllerBase()
		: base()
	{
	}
	private static ModulesDAO _Service; 
	public static ModulesDAO Service{
		get{
			if(_Service==null)
				_Service = new ModulesDAO();
			return _Service;
		}
		set{
			_Service = value;
		}
	}
    //Copy data from data row in grid to object
    public ModulesEntity MapDataRowToObject(DataRow row){
		ModulesEntity o = new ModulesEntity();
		 o.ModuleName=Convert.ToString(row["ModuleName"]);
		 o.Description=Convert.ToString(row["Description"]);
		 o.IconName=Convert.ToString(row["IconName"]);
		 o.ModuleLink=Convert.ToString(row["ModuleLink"]);
		 if(!row.IsNull("ModuleType"))
			o.ModuleType=ConvertByte(row["ModuleType"]);
		 if(!row.IsNull("ModuleId"))
		    o.ModuleId=(Int32)(row["ModuleId"]);
		 return o;
    }
	//Copy data from object to data row in grid    
    public void MapObjectToDataRow(ModulesEntity o,DataRow row){
		row["ModuleName"]=o.ModuleName;
		row["Description"]=o.Description;
		row["IconName"]=o.IconName;
		row["ModuleLink"]=o.ModuleLink;
		row["ModuleType"]=o.ModuleType;
		row["ModuleId"]=o.ModuleId;
    }
}
}
